package cn.com.dhcc.ddi.datamapping.vo;

import cn.com.dhcc.app.core.annotation.SiColumn;
import cn.com.dhcc.app.core.annotation.SiNotDbColumn;
import cn.com.dhcc.app.core.annotation.SiTable;
import cn.com.dhcc.app.core.base.ModuleFeatureBean;
import cn.com.dhcc.ddi.task.service.transform.TDataInterface;
import cn.com.dhcc.ddi.task.service.transform.impl.TDataFileExchangeImpl;
import cn.com.dhcc.ddi.task.service.transform.impl.TDataTableExchangeImpl;

import java.util.Date;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

/**
 * 数据映射表
 * @日期：2016/11/15 15:03
 * @作者：张洪涛
 * @版权所有：东华软件
 * @版本：1.0
 */
@SiTable(name = "t_ddi_ds_mapping")
public class DataMapping extends ModuleFeatureBean{
    @SiColumn(isId = true)
    private String id;
    @SiColumn(name = "mapping_name")
    private String mappingName;//映射名称

    @SiColumn(name = "src_ds_id")
    private String srcDsId;//源端数据源
    
    @SiNotDbColumn
    private String srcDsName;//源端数据源名称

    @SiColumn(name = "dest_ds_id")
    private String destDsId;//目的端数据源
    
    @SiNotDbColumn
    private String destDsName;//目的端数据源名称

    @SiColumn(name = "mapping_type")
    private String mappingType;//映射类型：1表到表、2表到文件、3文件到文件

    private Date mtime;//最后修改时间
    private String status;//状态
    private String remark;//备注

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getMappingName() {
        return mappingName;
    }

    public void setMappingName(String mappingName) {
        this.mappingName = mappingName;
    }

    public String getSrcDsId() {
        return srcDsId;
    }

    public void setSrcDsId(String srcDsId) {
        this.srcDsId = srcDsId;
    }

    public String getDestDsId() {
        return destDsId;
    }

    public void setDestDsId(String destDsId) {
        this.destDsId = destDsId;
    }

    public void setMappingType(String mappingType) {
        this.mappingType = mappingType;
    }

    public String getMappingType() {
        return mappingType;
    }

    public Date getMtime() {
        return mtime;
    }

    public void setMtime(Date mtime) {
        this.mtime = mtime;
    }
    
    public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getSrcDsName() {
		return srcDsName;
	}

	public void setSrcDsName(String srcDsName) {
		this.srcDsName = srcDsName;
	}

	public String getDestDsName() {
		return destDsName;
	}

	public void setDestDsName(String destDsName) {
		this.destDsName = destDsName;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}


	//映射类型：1结构化数据到结构化数据、2结构化数据到非结构化数据、3非结构化数据到非结构化数据
    public static enum MP_TYPE{
        TABLE_TO_TABLE("1","结构化数据<-->结构化数据",TDataTableExchangeImpl.class),
        TABLE_TO_FILE("2","结构化数据<-->非结构化数据",TDataTableExchangeImpl.class),
        FILE_TO_FILE("3","非结构化数据<-->非结构化数据",TDataFileExchangeImpl.class);
        private String code;
        private String name;
        private Class<? extends TDataInterface> handler;

        public String getCode() {
            return code;
        }

        public String getName() {
            return name;
        }

        public Class<? extends TDataInterface> getHandler() {
            return handler;
        }

        private static final Map lookup = new HashMap();

        static {
            for (MP_TYPE e : EnumSet.allOf(MP_TYPE.class)) {
                lookup.put(e.code, e);
            }
        }
        /**
         * 通code查找value
         * @param code
         * @return
         */
        public static MP_TYPE find(String code) {
            MP_TYPE value = (MP_TYPE) lookup.get(code);
            return value;
        }

        MP_TYPE(String code, String name, Class<? extends TDataInterface> handler) {
            this.code = code;
            this.name = name;
            this.handler = handler;
        }
    }
}
